package org.jeecg.modules.yw.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.yw.entity.EnterPrise;
import org.jeecg.modules.yw.entity.MaterialTemplate;
import org.jeecg.modules.yw.entity.Order;
import org.jeecg.modules.yw.service.EnterPriseService;
import org.jeecg.modules.yw.service.MaterialTemplateService;
import org.jeecg.modules.yw.service.OrderService;
import org.jeecg.modules.yw.utils.UserUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api(tags = "订单统计")
@RequestMapping("/orderStatic")
public class JsdController extends JeecgController<MaterialTemplate, MaterialTemplateService> {        
    @Resource
    private MaterialTemplateService materialService; 
    @Resource
    private OrderService orderSevice;
    
    @Resource
    private EnterPriseService entrSevice;
    /**
     * 导出excel
     *
     * @param request
     * @param orderId
     */
    //@RequiresPermissions("org.jeecg.modules:rewardspunish:exportXls")
    @GetMapping(value = "/exportJsXls")
    @ApiOperation(value = "导出結算单统计")
    public ModelAndView exportJsXls(HttpServletRequest request,
                                  @RequestParam(value = "orderId", required = false) String orderId) {
        List<MaterialTemplate> list= materialService.getMaterialTemplateList(orderId);
        String user= UserUtil.getUserName(request);
        String title = "结算单统计";
//        Order order = orderSevice.getOrder(orderId);
//        if (order != null) {
//        	EnterPrise ent = entrSevice.getById(order.getCreateUserId());
//        	if (ent!=null) {
//        		title =  "门窗企业:"+ent.getName()+",订单编号 :" + order.getOrderNo() + "  " + title;
//        	} else {
//        		title = "订单编号 :" + order.getOrderNo() + "   " + title;
//        	}
//        	
//        }

        return super.exportXls(list, MaterialTemplate.class,user, title);
    }
}
